BMEN90033 · Week 10 · Case Study
Back
BMEN90033 · WEEK 10 · CASE STUDY

Mean absolute value of an EMG signal, in real time.

The brief

As a biomedical engineer, you are designing a wearable EMG device. One of the functions your device needs to perform is to measure the mean absolute value of the signal in real time. Assume the input is a sinewave.

What functions would you need to perform on your signal to obtain the mean absolute value?

mean absolute value
$$ \mathrm{MAV} \;=\; \frac{1}{T}\int_{0}^{T} \bigl|\,x(t)\,\bigr|\,\mathrm{d}t $$
discrete form: $\;\mathrm{MAV} = \tfrac{1}{N}\sum_{n=1}^{N} |x[n]|$
EMG wearable MAV rectifier low-pass filter averaging
01the input

The signal and the target value.

The brief states the input is a sinewave, $x(t) = A\sin(\omega t)$. The mean absolute value is the time-average of $|x(t)|$ over a window $T$. For a sinewave with amplitude $A$ and a window that contains a whole number of half-cycles, the integral closes in form and the MAV settles to a constant.

continuous
$ \mathrm{MAV} = \tfrac{1}{T}\!\int_{0}^{T} |x(t)|\,\mathrm{d}t $
discrete (sampled)
$ \mathrm{MAV} = \tfrac{1}{N}\!\sum_{n=1}^{N} |x[n]| $

For $x(t) = A\sin(\omega t)$, evaluating the integral gives $\mathrm{MAV} = \tfrac{2A}{\pi} \approx 0.637\,A$. The target value below is plotted as a dashed line so the chain output in later slides can be read against it.

Two operations are required by the equation: take the absolute value of $x(t)$, then take the mean of that absolute value. The next slides build each operation from course primitives.
amplitude $A$ 1.00 V frequency 80 Hz
input signal · x(t) = A·sin(ωt) with target MAV = 2A/π
amplitude $A$1.00 V
target MAV— V
2A/π0.637·A
02two operations

Split the equation into two stages.

The MAV equation is the composition of two operators: an absolute value on the instantaneous signal, and an integral over a finite window. Each maps to a standard analog block.

step 1 · |·|
Take the absolute value
$\,y_1(t) = |x(t)|$. A negative half-cycle is reflected upwards. Implemented in hardware as a full-wave rectifier.
step 2 · ⟨·⟩
Take the running mean
$\,y_2(t) = \tfrac{1}{T}\!\int_{t-T}^{t} y_1(\tau)\,\mathrm{d}\tau$. The DC component of $y_1$ is the MAV; the AC ripple at $2\omega$ is rejected by a low-pass filter.

A rectified sinewave is a sum of a DC term equal to $\tfrac{2A}{\pi}$ and a Fourier series of even harmonics of $\omega$. Averaging, or low-pass filtering with cutoff well below $2\omega$, isolates that DC term.

The plot on the right marks the two stages on the same time axis: the input, the rectified signal, and the running mean. Slide 3 builds the rectifier; slide 4 builds the averaging stage; slide 5 connects them.
input · |x(t)| · running mean ⟨|x|⟩
stage 1full-wave rectify
stage 2low-pass / average
output2A/π
03stage 1 · full-wave rectifier

A precision rectifier implements $|x(t)|$.

A passive bridge of four diodes will rectify a sinewave, but each diode drop subtracts $V_D \approx 0.6$ V from the signal. EMG amplitudes are millivolts, so the diodes never turn on. A precision rectifier places the diode inside an op-amp feedback loop, dividing the diode drop by the open-loop gain so the output follows $|x(t)|$ down to nearly zero.

For a sinewave input $x(t) = A\sin(\omega t)$, the rectified output is

$|x(t)| \;=\; A\bigl|\sin(\omega t)\bigr| \;=\; \dfrac{2A}{\pi} \;-\; \dfrac{4A}{\pi}\!\sum_{k=1}^{\infty}\!\dfrac{\cos(2k\omega t)}{4k^{2}-1}$

The first term is the DC value the next stage must extract. The remaining terms are harmonics of $2\omega$, the lowest of which is at $2\omega$ itself. A low-pass filter with cutoff well below $2\omega$ removes them.

// strengths
  • Reflects negative half-cycles upwards exactly, with no diode-drop offset.
  • Works on signals as small as a few millivolts, which a passive bridge cannot.
  • Output is a continuous function, so the next stage averages without gating.
// weaknesses
  • Requires a dual-supply op-amp with adequate slew rate at the EMG bandwidth.
  • Output contains harmonics of $2\omega$ that must be filtered before display.
Slide the input amplitude to confirm that the rectified output tracks $A|\sin(\omega t)|$ even at small amplitudes. The dashed line marks $2A/\pi$, the DC level the next stage will recover.
amplitude $A$ 1.00 V frequency 80 Hz
input x(t) · rectified output |x(t)| · DC level 2A/π
peak |x|— V
DC component— V
lowest harmonic— Hz
04stage 2 · averaging

A low-pass filter extracts the mean.

Averaging in continuous time is integration over a window. A first-order RC low-pass filter is the analog approximation: the output is a weighted moving average of the input with an exponential window of time constant $\tau = RC$ and cutoff $f_c = 1/(2\pi\tau)$.

The rectified signal is a DC term at $\tfrac{2A}{\pi}$ plus harmonics at $2\omega, 4\omega, \dots$. A first-order low-pass filter at cutoff $f_c$ has magnitude $|H(f)| = 1/\sqrt{1 + (f/f_c)^2}$. Choosing $f_c \ll 2f_\mathrm{sig}$ attenuates every harmonic; the DC term passes unchanged, so the filter output settles to $\tfrac{2A}{\pi}$, which is the MAV.

// strengths
  • Single resistor and capacitor; trivially small on a wearable PCB.
  • Cutoff $f_c$ trades off ripple against settling time directly via $\tau = RC$.
  • DC gain is unity, so the output reads the MAV in volts without a calibration constant.
// weaknesses
  • Lower $f_c$ means slower response: the device cannot follow sudden envelope changes.
  • First-order roll-off is gentle ($-20$ dB/decade); residual $2\omega$ ripple is always present unless cascaded.
Lower the cutoff to suppress ripple but watch the output take longer to settle. The dashed line marks the analytic target $\tfrac{2A}{\pi}$, so any offset visible at steady state is residual ripple, not bias.
cutoff $f_c$ 5.0 Hz frequency 80 Hz
rectified |x(t)| · low-pass output y(t) · target 2A/π
cutoff5.0 Hz
τ = RC— ms
steady-state— V
05the full chain

The block diagram that computes MAV.

The two stages connect in series. The EMG sinewave enters the precision rectifier, the rectified signal feeds a first-order low-pass filter, and the filter output is the running mean absolute value. The chain is purely analog and runs continuously, so the output is available in real time without sampling or accumulation in software.

  • Pre-amp (instrumentation amplifier) lifts the millivolt EMG to a level that drives the rectifier's op-amp safely above its input-referred noise.
  • Precision rectifier outputs $|x(t)|$ with no diode-drop offset.
  • Low-pass filter at cutoff $f_c \ll 2f_\mathrm{sig}$ extracts the DC component, which equals $\tfrac{2A}{\pi}$ and is the MAV.
The plot shows the input sinewave, the rectified signal, and the filter output on a shared time axis. Adjust the cutoff to confirm the output approaches $\tfrac{2A}{\pi}$ marked by the dashed line.
amplitude $A$ 1.00 V frequency 80 Hz cutoff $f_c$ 5.0 Hz
input x(t) · rectified |x(t)| · MAV output y(t)
block diagram · EMG input → precision rectifier → low-pass filter → MAV
target 2A/π— V
measured MAV— V
error— %
06application · myoelectric prosthesis

MAV drives a prosthetic gripper.

A myoelectric prosthetic hand is controlled by surface EMG from the residual limb. The raw signal is bipolar and noisy; the controller cannot use it directly. The MAV envelope is the quantity that correlates with voluntary contraction force, so the chain from the previous slide is what the device runs in real time.

  • Detection — a threshold on the MAV separates a voluntary contraction from baseline activity, so the gripper only engages when the user intends to grip.
  • Proportional control — once above threshold, the MAV value sets motor drive, so a stronger contraction produces a firmer grip.
  • Smoother choice — three options for the averaging stage are provided. The first-order LPF is the analog default; the moving-window average is the literal $\tfrac{1}{T}\!\int|x|\,\mathrm{d}t$; a 1-D Kalman filter adapts its gain as the variance evolves and gives the cleanest envelope.
  • Latency vs. smoothness — the smoothing parameter $f_c$ sets the bandwidth of all three. Lower $f_c$ rejects more EMG burst noise but lengthens the delay between intent and grip. $f_c = 0$ is the limit of pure averaging.
Drag the effort slider to simulate a contraction. Switch between the three smoothers and lower $f_c$ toward zero to see the trace flatten. The Kalman option gives the smoothest envelope at the same response time, because it weights new measurements against the running variance instead of using a fixed time constant.
muscle effort 0 % 1st-order LPF moving avg kalman smoothing $f_c$ 2.0 Hz threshold 0.18 V
live EMG x(t) · MAV envelope y(t) · threshold
prosthetic gripper · jaw angle ∝ grip force ∝ MAV
MAV— V
grip force0 %
stateRELAXED
1 / 7